<?php
	global $ubi;
	
	for ($i = 0; $i < count($comments); $i++) {
		$com = $comments[$i];			
		$user = $users[$i];
		$img = $imgs[$user->getUserID()];	
?>
	<div class="post">
		<div class="comment">
	    	<div style="text-align:center">	    		
	        	<a href="index.php?view&type=user&userid=<?php echo $user->getUserID(); ?>">
	        		<img src="<?php echo $ubi['SERVER']['THUMBNAIL_PATH'] . "/" . $img ?>" class="smallAvatar" />	            	
	            </a>                                    
	            <a href="index.php?view&type=user&userid=<?php echo $user->getUserID(); ?>">
	            	<?php echo $user->getUsername();?>
	            </a>    
	        </div>
	        <?php
	        	if (isset($_SESSION['userid']) && $_SESSION['userid'] && $_SESSION['userid'] != $user->getUserID()) { 
	        ?>
		        <p class="comment-link">
		        	<a class="a_cursor" title="Gửi Tin Nhắn" onclick="$.sendMessage(<?php echo $user->getUserID()?>)">Gửi Tin Nhắn</a>
					<br />
		            <a class="a_cursor" title="Kết Bạn" onclick="$.makeFriend(<?php echo $user->getUserID()?>)">Kết Bạn</a>                                
		        </p>
	        <?php
	        	} 
	        ?>
	    </div>
	    <div class="right" id="comment_content<?php echo $com->getCommentID()?>">
	    	<?php
	    		include 'viewOneComment.php' 
	    	?>
			<div style="clear:both"></div>
	    </div>
	    <div class="clear" style="clear:both"></div>                                
	</div>		
<?php
	} 
?>
<div class="page">
	<?php
		if ($numberOfPages > 0) {
		echo 'Trang :'; 
		for ($i = 0; $i < $numberOfPages; $i++) {
			if ($i + 1 != $getVars['page']) {
	?>
			<a href="#allComments" onclick="$.viewPage('<?php echo $i + 1 ?>')"><?php echo $i + 1 ?></a>&nbsp;
	<?php 
			} else {
				?>
				<b><a href="#allComments" onclick="$.viewPage('<?php echo $i + 1 ?>')"><?php echo $i + 1 ?></a></b>&nbsp;
				<?php
			}
		} 
		}
	?>			
</div>

<script type="text/javascript" language="javascript">
	$.extend({		
		viewPage:function(page) {
			var url = 'index.php?comment&action=load&interactType=<?php echo $getVars['interactType'] ?>&indicteeID=<?php echo $getVars['indicteeID'] ?>';
			url += '&page=' + page;
			$('#allComments').load(url);
		},
		plusComment:function(id) {
			var url = 'index.php?comment&action=plus&commentID=' + id;	
			$('#comment_content' + id).load(url);
		},	
		minusComment:function(id) {
			var url = 'index.php?comment&action=minus&commentID=' + id;	
			$('#comment_content' + id).load(url);
		}			
	});
</script>